﻿using System;
using System.Collections.Generic;
using System.Linq;

using Caliburn.Micro;

using Haushaltsbuch.ViewModels.Interfaces;

namespace Haushaltsbuch.ViewModels.Options
{
    public class ChangePasswordViewModel : Screen, IDialog
    {
        private string password1;
        private string password2;
        public bool IsCanceled { get; set; }

        public string Password1
        {
            get { return this.password1; }
            set
            {
                if (value == this.password1) return;
                this.password1 = value;
                this.NotifyOfPropertyChange(() => this.Password1);
                this.NotifyOfPropertyChange(() => this.CanOk);
            }
        }

        public string Password2
        {
            get { return this.password2; }
            set
            {
                if (value == this.password2) return;
                this.password2 = value;
                this.NotifyOfPropertyChange(() => this.Password2);
                this.NotifyOfPropertyChange(() => this.CanOk);
            }
        }

        public bool CanOk
        {
            get { return this.Password1 == this.Password2; }
        }

        public void Ok()
        {
            this.IsCanceled = false;
            this.TryClose();
        }

        public void Cancel()
        {
            this.IsCanceled = true;
            this.TryClose();
        }
    }
}